/* GUI CONVERTED from rsshmt01.p (converter v1.76) Fri Aug 23 22:30:00 2002 */
/* rsshmt01.p - PO SHIPPER MAINTENANCE COMPONENT ISSUE                        */
/* Copyright 1986-2002 QAD Inc., Carpinteria, CA, USA.                        */
/* All rights reserved worldwide.  This is an unpublished work.               */
/*V8:ConvertMode=Maintenance                                                  */
/* $Revision: 1.8 $                                                           */

/* Revision: 1.3          BY: Ashwini G.         DATE: 11/23/01  ECO: *M16H*  */
/* Revision: 1.4          BY: Jean Miller        DATE: 05/22/02  ECO: *P074*  */
/* Revision: 1.6          BY: Ashish Maheshwari  DATE: 07/17/02  ECO: *N1GJ*  */
/* $Revision: 1.8 $       BY: Gnanasekar         DATE: 08/19/02  ECO: *M202*  */
/******************************************************************************/
/* All patch markers and commented out code have been removed from the source */
/* code below. For all future modifications to this file, any code which is   */
/* no longer required should be deleted and no in-line patch markers should   */
/* be added.  The ECO marker should only be included in the Revision History. */
/******************************************************************************/

/* DISPLAY TITLE */
{mfdeclre.i}
{gplabel.i}

/* ********** End Translatable Strings Definitions ********* */
define input parameter sodnbr    like sod_nbr        no-undo.
define input parameter sodln     like sod_line       no-undo.
define input parameter qtychg    like sod_qty_chg    no-undo.
define input parameter srsite    like sod_site       no-undo.
define input parameter srloc     like sod_loc        no-undo.
define input parameter ponbr     like po_nbr         no-undo.
define input parameter shipfrom  like abs_shipfrom   no-undo.
define input parameter shipid    like abs_id         no-undo.
define input parameter dirship   like mfc_logical    no-undo.

define new shared variable part          like wod_part    no-undo.
define new shared variable undo-input    like mfc_logical .
define new shared variable pk_recno      as recid         no-undo.

define shared variable site                like sr_site           no-undo.
define shared variable location            like sr_loc            no-undo.
define shared variable lotserial           like sr_lotser         no-undo.
define shared variable lotref              like sr_ref            no-undo.
define shared variable lotserial_qty       like sr_qty            no-undo.
define shared variable change_db           like mfc_logical    .
define shared variable total_lotserial_qty like  sr_qty .
define shared variable multi_entry         like mfc_logical
                                         label "Multi Entry" no-undo.
define shared variable lotserial_control   like pt_lot_ser .
define shared variable cline               as character    .

define shared variable trans_conv          like pod_um_conv .

define variable l_trans_um    like pt_um                  no-undo.
define variable nbr           like wo_nbr                 no-undo.
define variable qopen         like wod_qty_all label "Qty Open "
                                                        no-undo.
define variable yn            like mfc_logical            no-undo.
define variable ref           like glt_ref                no-undo.
define variable desc1         like pt_desc1               no-undo.
define variable i             as integer                  no-undo.
define variable qty_left      like tr_qty_chg             no-undo.
define variable del-yn        like mfc_logical initial no no-undo.
define variable j             as integer                  no-undo.
define variable firstpass     like mfc_logical            no-undo.
define variable backflush_qty like wod_qty_chg            no-undo.
define variable pm_code       like pt_pm_code             no-undo.
define variable lotnext       like wo_lot_next            no-undo.
define variable lotprcpt      like wo_lot_rcpt            no-undo.

define buffer ptmaster for pt_mstr.
define buffer absmstr for abs_mstr.

FORM /*GUI*/ 
   pk_part
   pk_qty       label "Qty Open " format "->>>>,>>9.9<<<<<<"
with frame c 8 down
scroll 8 no-attr-space width 80
title color normal (getFrameTitle("RECEIPT_DATA_INPUT",24))
row 4 overlay BGCOLOR 8 /*GUI*/.


/* SET EXTERNAL LABELS */
setFrameLabels(frame c:handle).


FORM /*GUI*/ 
   
 RECT-FRAME       AT ROW 1 COLUMN 1.25
 RECT-FRAME-LABEL AT ROW 1 COLUMN 3 NO-LABEL VIEW-AS TEXT SIZE-PIXELS 1 BY 1
 SKIP(.1)  /*GUI*/
part          colon 13 pt_um  site        colon 54
   location      colon 68 label "Loc"
   pt_desc1      colon 13       lotserial    colon 54
   lotserial_qty colon 13       lotref       colon 54
   multi_entry   colon 54
 SKIP(.4)  /*GUI*/
with frame d side-labels width 80 attr-space
/*V8+*/  NO-BOX THREE-D /*GUI*/.

 DEFINE VARIABLE F-d-title AS CHARACTER INITIAL "".
 RECT-FRAME-LABEL:SCREEN-VALUE in frame d = F-d-title.
 RECT-FRAME-LABEL:HIDDEN in frame d = yes.
 RECT-FRAME:HEIGHT-PIXELS in frame d =
  FRAME d:HEIGHT-PIXELS - RECT-FRAME:Y in frame d - 2.
 RECT-FRAME:WIDTH-CHARS IN FRAME d = FRAME d:WIDTH-CHARS - .5.  /*GUI*/


/* SET EXTERNAL LABELS */
setFrameLabels(frame d:handle).

for first sod_det
   fields(sod_line sod_nbr sod_part sod_qty_ord
          sod_site sod_um sod_um_conv)
   where sod_nbr  = sodnbr
     and sod_line = sodln no-lock:
end. /* FOR FIRST sod_det */


for first pt_mstr
   fields(pt_desc1 pt_desc2 pt_loc pt_lot_ser
          pt_part pt_pm_code pt_um)
   where pt_part = sod_part no-lock:
end. /* FOR FIRST PT_MSTR */


mainloop:
repeat on error undo mainloop, leave mainloop:

   clear frame c.
   hide frame c.
   hide frame d.

   do transaction:

      for each sr_wkfl exclusive-lock
         where sr_userid = mfguser
           and sr_lineid begins string(sod_line) + "ISS":
         delete sr_wkfl.
      end. /* FOR EACH sr_wkfl */

      for each lotw_wkfl
         where lotw_mfguser = mfguser
      exclusive-lock:
         delete lotw_wkfl.
      end. /* FOR EACH lotw_wkfl */

      for each pk_det exclusive-lock
         where pk_user = mfguser:
         delete pk_det.
      end. /* FOR EACH pk_det */

      for each sob_det
         fields(sob_line sob_loc sob_nbr sob_part sob_qty_req sob_site)
         where sob_nbr     = sod_nbr
           and sob_line    = sod_line
           and sob_qty_req <> 0
      no-lock break by sob_part :

         if first-of (sob_part)
         then
            ponbr = "".

         assign
            ponbr = shipid + ponbr
            cline = string(sob_line) + "ISS".

         /* CREATE sr_wkfl RECORDS FOR EXISTING COMPONENT RECORDS */
         for first absmstr
            fields ( abs_id abs_item abs_line abs_loc abs_lotser
                     abs_par_id abs_qty abs_ref abs_shipfrom abs_site )
             where absmstr.abs_shipfrom = shipfrom
               and absmstr.abs_id       begins   ponbr
               and absmstr.abs_par_id   begins   ponbr
               and absmstr.abs_item     = sob_part
               and absmstr.abs_line     = string (sob_line)
         no-lock:
         end. /* FOR FIRST absmstr */

         if available absmstr
         then do:

            for each absmstr
               fields ( abs_id abs_item abs_line abs_loc abs_lotser
                        abs_par_id abs_qty abs_ref abs_shipfrom abs_site )
               where absmstr.abs_shipfrom = shipfrom
                 and absmstr.abs_id       begins   ponbr
                 and absmstr.abs_par_id   begins   ponbr
                 and absmstr.abs_item     = sob_part
                 and absmstr.abs_line     = string (sob_line)
            no-lock:

               create sr_wkfl.
               assign
                  sr_userid = mfguser
                  sr_lineid = cline + absmstr.abs_item
                  sr_site   = absmstr.abs_site
                  sr_loc    = absmstr.abs_loc
                  sr_lot    = absmstr.abs_lot
                  sr_qty    = absmstr.abs_qty
                  sr_ref    = absmstr.abs_ref .

               if recid(sr_wkfl) = -1
               then .
            end.  /* FOR EACH  absmstr */

         end.  /* IF AVAILABLE absmstr */

         /* PLACE NON-CONFIGURED S.O. BILL ITEMS IN PACK LIST DETAIL */
         pm_code = "".

         for first ptmaster
            fields(pt_desc1 pt_desc2 pt_loc pt_lot_ser
                   pt_part pt_pm_code pt_um)
            where ptmaster.pt_part = sob_part
         no-lock:
         end. /* FOR FIRST ptmaster */

         if available ptmaster
         then
            pm_code = ptmaster.pt_pm_code.

         for first ptp_det
            fields(ptp_part ptp_pm_code ptp_site)
            where ptp_part = sob_part
              and ptp_site = sob_site
         no-lock:
         end. /* FOR FIRST ptp_det */

         if available ptp_det
         then
            pm_code = ptp_pm_code.

         if pm_code <> "C"
         then do:

            find first pk_det
               where pk_user = mfguser
                 and pk_part = sob_part
            exclusive-lock no-error.

            if not available pk_det
            then do:
               create pk_det.
               assign
                  pk_user = mfguser
                  pk_part = sob_part
                  pk_loc  = sob_loc.

               if recid(pk_det) = -1
               then .
            end. /* IF NOT AVAILABLE pk_det .. */

            if  sod_um_conv <> 0
            and sod_qty_ord <> 0
            then
               pk_qty = pk_qty + (sob_qty_req / sod_um_conv / sod_qty_ord)
                                * qtychg   * trans_conv.
         end. /* if pm_code <> C */

      end.  /*  FOR EACH sob_det ... */

      cline = string(sod_line) + "ISS".

      define variable any_rejected like mfc_logical no-undo.
      any_rejected = no.


      for each pk_det
         fields(pk_loc pk_part pk_qty pk_user)
         where pk_user = mfguser
      no-lock:

         find first sr_wkfl
            where sr_userid = mfguser
              and sr_lineid = cline + pk_part
              and sr_site   = srsite
              and sr_loc    = pk_loc
         exclusive-lock no-error.

         /* VALIDATE SHIP-FROM LOCATIONS */
         define buffer ptmstr for pt_mstr.
         define variable rejected like mfc_logical no-undo.

         for first ptmstr
            fields(pt_desc1 pt_desc2 pt_loc pt_lot_ser
                   pt_part pt_pm_code pt_um)
            where ptmstr.pt_part = pk_part
         no-lock:
         end. /* FOR FIRST ptmstr */

         find first sr_wkfl
            where sr_userid = mfguser
              and sr_lineid = cline + pk_part
              and sr_site   = srsite
              and sr_loc    = pk_loc
         exclusive-lock no-error.

         if not available sr_wkfl
         then do:

            create sr_wkfl.
            assign
               sr_userid = mfguser
               sr_lineid = cline + pk_part
               sr_site   = srsite
               sr_loc    = pk_loc.

            if recid(sr_wkfl) = -1
            then .
         end. /* IF NOT AVAILABLE sr_wkfl */

      end.  /* FOR EACH pk_det  */

      if not batchrun
      then
         if any_rejected
         then
            pause.

      /* MAKE SURE THERE IS AT LEAST ONE SR_WKFL RECORD FOR EACH PK_DET*/
      for each pk_det
         fields(pk_loc pk_part pk_qty pk_user)
         where pk_user = mfguser
      no-lock:

         for first sr_wkfl
            fields(sr_lineid sr_loc sr_lotser sr_qty
                   sr_ref sr_site sr_userid)
            where sr_userid = mfguser
              and sr_lineid = cline + pk_part
         no-lock:
         end. /* FOR FIRST sr_wkfl */

         if not available sr_wkfl
         then do:
            create sr_wkfl.
            assign
               sr_userid = mfguser
               sr_lineid = cline + pk_part
               sr_site   = srsite
               sr_loc    = pk_loc.
            if recid(sr_wkfl) = -1
            then .
         end. /* IF NOT AVAILABLE sr_wkfl */

      end.  /* FOR EACH pk_det */

   end. /* DO TRANSACTION */

   pk_recno = ?.

   seta:
   repeat:
/*GUI*/ if global-beam-me-up then undo, leave.


      do transaction on error undo seta, leave seta:
/*GUI*/ if global-beam-me-up then undo, leave.


         setb:
         repeat:
/*GUI*/ if global-beam-me-up then undo, leave.


             clear frame d.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame d = F-d-title.
             view  frame d.

             /* DISPLAY DETAIL */
             setc:
             repeat on endkey undo, leave
             with frame c:
/*GUI*/ if global-beam-me-up then undo, leave.

                 if not batchrun
                 then do:
                    {icswndow.i
                        &file1=pk_det
                        &file2=sr_wkfl
                        &framename="c"
                        &record-id=pk_recno
                        &search1=pk_user
                        &equality1=mfguser
                        &search2="sr_userid = mfguser
                                    and sr_lineid = string(sod_line)
                                     + """ISS""" + pk_part"
                        &scroll-field=pk_part
                        &update-leave=yes
                        &display11=pk_part
                        &display12=pk_qty
                        &display21=sr_site
                        &display22=sr_loc
                        &display23=sr_lotser
                        &display30=sr_ref
                        &display24="sr_qty format """->>>>>>9.9<<<<<<"""
                             column-label ""Qty to Rec"" "}

                 end. /* IF NOT batchrun .. */

                 if keyfunction(lastkey) = "end-error"
                 then
                    leave.

                 pause 0.
                 clear frame d.
/*GUI*/ RECT-FRAME-LABEL:SCREEN-VALUE in frame d = F-d-title.

                 setd:
                 repeat on error undo, retry with frame d:

                    part = "".

                    if pk_recno <> ?
                    then do:
                       for first pk_det
                          fields(pk_loc pk_part pk_qty pk_user)
                          where recid(pk_det) = pk_recno
                       no-lock:
                       end. /* FOR FIRST pk_det */

                       if available pk_det
                       then
                          part = pk_part.
                    end.  /* IF pk_recno .. */

                    display part.

                    for first pt_mstr
                       fields(pt_desc1 pt_desc2 pt_loc pt_lot_ser
                           pt_part pt_pm_code pt_um)
                       where pt_part = part
                    no-lock:
                    end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* FOR FIRST pt_mstr */

                    if available pt_mstr
                    then
                       display pt_desc1.
                    else
                       display "" @ pt_desc1.

                    input clear.

                    update
                       part
                    with frame d editing:

                       if frame-field = "part"
                       then do:

                          /* FIND NEXT/PREVIOUS RECORD */
                          {mfnp01.i pk_det part pk_part mfguser
                                   pk_user pk_det}
                          if recno <> ?
                          then do:
                             part = pk_part.
                             display part with frame d.

                             for first pt_mstr
                                fields(pt_desc1 pt_desc2 pt_loc
                                       pt_lot_ser pt_part
                                       pt_pm_code pt_um)
                                where pt_part = part
                             no-lock:
                             end. /* FOR FIRST pt_mstr */

                             if available pt_mstr
                             then do:
                                display pt_um pt_desc1 with frame d.
                             end.  /* IF AVAILABLE pt_mstr */

                          end. /* IF recno <> */

                       end. /* IF frame-field = .. */

                       else do:
                          status input.
                          readkey.
                          apply lastkey.
                       end.  /* ELSE DO */

                    end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* UPDATE ... */

                    status input.

                    assign part.
                    if part = ""
                    then
                       leave setc.

                    for first pt_mstr
                       fields(pt_desc1 pt_desc2 pt_loc pt_lot_ser
                              pt_part pt_pm_code pt_um)
                       where pt_part = part
                    no-lock:
                    end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* FOR FIRST pt_mstr */

                    if not available pt_mstr
                    then do:
                       {pxmsg.i &MSGNUM=16 &ERRORLEVEL=3}
                       undo, retry.
                    end. /* IF NOT AVAILABLE pt_mstr */

                    assign
                       part      = pt_part
                       cline     = string(sod_line) + "ISS" + pt_part
                       firstpass = yes.

                    frame-d-loop:
                    repeat:
/*GUI*/ if global-beam-me-up then undo, leave.


                       multi_entry = no.

                       find first pk_det
                          where pk_user = mfguser
                            and pk_part = part
                       exclusive-lock no-error.

                       if not available pk_det
                       then do:
                          /* PART DOES NOT EXIST ON THIS */
                          /* BILL OF MATERIAL */
                          {pxmsg.i &MSGNUM=547 &ERRORLEVEL=2}
                          create pk_det.
                          assign
                             pk_user = mfguser
                             pk_part = part.
                          if recid(pk_det) = -1
                          then .
                       end.  /* IF NOT AVAILABLE pk_det */

                       for first pt_mstr
                          fields(pt_desc1 pt_desc2 pt_loc pt_lot_ser
                                 pt_part pt_pm_code pt_um)
                          where pt_part = part
                       no-lock:
                       end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* FOR FIRST pt_mstr */

                       if not available pt_mstr
                       then do:
                          {pxmsg.i &MSGNUM=16 &ERRORLEVEL=2}
                          display
                             part
                             " " @ pt_um
                             " " @ pt_desc1
                          with frame d.
                       end. /* IF NOT AVAILABLE pt_mstr */
                       else do:
                          if new pk_det
                          then
                             pk_loc = pt_loc.
                          display
                             pt_part @ part
                             pt_um
                             pt_desc1
                          with frame d.
                       end. /* ELSE DO */

                       assign
                          qopen     = pk_qty
                          lotserial_control = ""
                          site      = ""
                          location  = ""
                          lotserial = ""
                          lotref    = "".

                       if available pt_mstr
                       then
                          lotserial_control = pt_lot_ser.

                       assign
                          cline       = string(sod_line) + "ISS" + pk_part
                          global_part = pk_part
                          lotserial_qty = 0.

                       for first sr_wkfl
                          fields(sr_lineid sr_loc sr_lotser sr_qty
                                sr_ref sr_site sr_userid)
                         where sr_userid = mfguser
                           and sr_lineid = cline
                       no-lock:
                       end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* FOR FIRST sr_wkfl */

                       if available sr_wkfl
                       then do:

                          assign
                             site      = sr_site
                             location  = sr_loc
                             lotserial = sr_lotser
                             lotref    = sr_ref
                             i = 0.

                          for each sr_wkfl
                             fields(sr_lineid sr_loc sr_lotser sr_qty
                                    sr_ref sr_site sr_userid)
                             where sr_userid = mfguser
                               and sr_lineid = cline
                          no-lock:
                             assign
                                i = i + 1
                                lotserial_qty = lotserial_qty + sr_qty.
                          end. /* FOR EACH sr_wkfl */

                          if i > 1
                          then do:
                             assign
                                multi_entry = yes
                                site        = ""
                                location    = ""
                                lotserial   = ""
                                lotref      = "".
                          end. /* IF i > 1 */

                       end. /* IF AVAILABLE sr_wkfl */

                       else do:
                          assign
                             site     = srsite
                             location = if srloc > ""
                                        then
                                           srloc
                                        else
                                           pk_loc.
                       end. /* ELSE DO */

                       locloop:
                       do on error undo, retry
                          on endkey undo frame-d-loop, leave:

                          assign
                             pk_recno    = recid(pk_det)
                             global_part = pk_part.

                          if dirship = yes
                          then do:
                             for first soc_ctrl
                                fields (soc_dum_loc)
                                no-lock:
                                location = soc_dum_loc.
                                display soc_dum_loc @ location with frame d.
                             end. /* FOR FIRST soc_ctrl */
                          end. /* IF dirship = yes */

                          update
                             lotserial_qty
                             site
                             location      when (not dirship)
                             lotserial
                             lotref
                             multi_entry
                          with frame d
                          editing:
                             assign
                                global_site = input site
                                global_loc = input location.
                             readkey.
                             apply lastkey.
                          end. /* UPDATE ... */

                          i = 0.

                          for each sr_wkfl
                             fields(sr_lineid sr_loc sr_lotser sr_qty
                                    sr_ref sr_site sr_userid)
                             where sr_userid = mfguser
                               and sr_lineid = cline
                          no-lock:
                             i = i + 1.
                             if i > 1
                             then
                                leave.
                          end. /* FOR EACH sr_wkfl .. */

                          if i > 1
                          then
                             multi_entry = yes.

                          total_lotserial_qty = pk_qty.

                          if multi_entry
                          then do:
                             assign
                                lotnext  = ""
                                lotprcpt = no.

                             if available pt_mstr
                             then
                                l_trans_um = pt_um.

                             /* CHANGED SIXTH INPUT PARAMETER FROM no TO */
                             /* dirship TO INDICATE DIRECT SHIPMENT      */
                             {gprun.i ""icsrup.p""
                                "(input sod_site,
                                  input """",
                                  input """",
                                  input-output lotnext,
                                  input lotprcpt,
                                  input dirship)"}
/*GUI*/ if global-beam-me-up then undo, leave.

                          end. /* IF multi_entry */

                          else do with frame d:

                             {gprun.i ""icedit.p""
                                "(input ""rct-fas"",
                                  input site,
                                  input location,
                                  input pk_part,
                                  input lotserial,
                                  input lotref,
                                  input lotserial_qty,
                                  input if available pt_mstr
                                        then
                                           pt_um
                                        else """",
                                  input """",
                                  input """",
                                  output undo-input)" }
/*GUI*/ if global-beam-me-up then undo, leave.


                             if undo-input
                             then
                                undo, retry.

                             if sod_site <> site
                             then do:

                                if available pt_mstr
                                then
                                   l_trans_um = pt_um.

                                {gprun.i ""icedit4.p""
                                   "(input ""rct-fas"",
                                     input sod_site,
                                     input site,
                                     input pt_loc,
                                     input location,
                                     input pk_part,
                                     input lotserial,
                                     input lotref,
                                     input lotserial_qty,
                                     input l_trans_um,
                                     input """",
                                     input """",
                                     output yn)" }
/*GUI*/ if global-beam-me-up then undo, leave.


                                if yn
                                then
                                   undo locloop, retry.

                             end. /* IF sod_site <>  .. */

                             find first sr_wkfl
                                where sr_userid = mfguser
                                  and sr_lineid = cline
                             exclusive-lock no-error.

                             if lotserial_qty = 0
                             then do:
                                if available sr_wkfl
                                then do:
                                   assign
                                      total_lotserial_qty =
                                         total_lotserial_qty - sr_qty
                                                   sr_qty = 0.
                                end. /* IF AVAILABLE sr_wkfl */
                             end. /* IF lotserial_qty = 0 */

                             else do:
                                if not available sr_wkfl
                                then do:
                                   create sr_wkfl.
                                   assign
                                      sr_userid = mfguser
                                      sr_lineid = cline.
                                   if recid(sr_wkfl) = -1
                                   then .
                                end. /* IF NOT AVAILABLE sr_wkfl */
                                assign
                                   total_lotserial_qty =
                                         total_lotserial_qty
                                         - sr_qty + lotserial_qty
                                   sr_site = site
                                   sr_loc = location
                                   sr_lotser = lotserial
                                   sr_ref = lotref
                                   sr_qty = lotserial_qty.
                             end. /* ELSE DO */

                          end. /* ELSE DO with frame d */

                       end. /* REPEAT WITH FRAME D */

                       leave.

                    end. /* REPEAT WITH FRAME D-LOOP */

                 end. /* REPEAT ON ERROR UNDO, RETRY WITH FRAME D */

                 if batchrun
                 then
                    leave.
             end. /* REPEAT ON ENDKEY UNDO, LEAVE WITH FRAME C */

             repeat:
/*GUI*/ if global-beam-me-up then undo, leave.


                yn = yes.
                /* DISPLAY ITEMS TO RECEIVE */
                {pxmsg.i &MSGNUM=660 &ERRORLEVEL=1 &CONFIRM=yn}

                if yn = yes
                then do:

                   hide frame c no-pause.
                   hide frame d no-pause.

                   for each pk_det
                       fields(pk_loc pk_part pk_qty pk_user)
                       where pk_user = mfguser no-lock
                   with frame e down row 4 overlay:

                      display
                         pk_part
                         pk_qty label "Qty Open "
                                format "->>>,>>9.9<<<<<".

                      for each sr_wkfl
                         fields(sr_lineid sr_loc sr_lotser sr_qty
                                sr_ref sr_site sr_userid)
                         where sr_userid = mfguser
                           and sr_lineid = string(sod_line) + "ISS" + pk_part
                           and sr_qty <> 0
                       no-lock
                      with frame e width 80
                      title (getFrameTitle("RECEIPT_DATA_REVIEW",25))
                      break by sr_site by sr_loc by sr_lotser by sr_ref:

                         if first-of(sr_lotser)
                         then do:
                            display
                               sr_site
                               sr_loc
                               sr_lotser column-label "Lot/Serial!Ref".
                            if sr_ref <> " " then
                               down 1.
                         end. /* IF FIRST-OF sr_lotser */

                         display
                            sr_ref format "x(8)"
                               when (sr_ref <> "")   @ sr_lotser
                            sr_qty column-label "Receipt Qty"
                               format "->>>,>>9.9<<<<<".
                         down 1.

                      end. /* FOR EACH sr_wkfl */

                      up 1.

                   end. /* FOR EACH pk_det */

                end. /* IF yn = ... */

                leave.

             end.
/*GUI*/ if global-beam-me-up then undo, leave.
 /* REPEAT .. */

             do on endkey undo mainloop,  leave mainloop:
                yn = yes.

                /* Is all information correct */
                {pxmsg.i &MSGNUM=12 &ERRORLEVEL=1 &CONFIRM=yn}
                     
                if yn = ?
                then
                   undo seta, leave seta.   

             end. /* DO ON ENDKEY ... */

             if yn
             then do:

                for each pk_det
                    fields(pk_loc pk_part pk_qty pk_user)
                    where pk_user = mfguser no-lock,
                    each sr_wkfl
                       fields(sr_lineid sr_loc sr_lotser sr_qty
                               sr_ref sr_site sr_userid)
                       where sr_userid = mfguser
                         and sr_lineid = string(sod_line) + "ISS" + pk_part
                         and sr_qty <> 0
                no-lock:

                   for first pt_mstr
                       fields(pt_desc1 pt_desc2 pt_loc pt_lot_ser
                             pt_part pt_pm_code pt_um)
                       where pt_part = pk_part
                   no-lock:
                   end. /* FOR FIRST pt_mstr */

                   if available pt_mstr
                      and index("LS",pt_lot_ser) > 0
                      and sr_lotser = ""
                   then do:
                      pk_recno = recid(pk_det).
                      {pxmsg.i &MSGNUM=1119 &ERRORLEVEL=3}
                      next setb.
                   end. /* IF AVAILABLE pt_mstr */

                end. /* FOR EACH pk_det */

                hide frame c.
                hide frame d.
                hide frame e.
                leave mainloop.

             end. /* IF yn ... */

          end. /* SETB */

       end. /* DO ON ERROR ... */

       leave.

    end. /* REPEAT FOR SETA */

    clear frame c.
    hide frame c.
    hide frame d.

end. /* MAINLOOP */

 hide frame d.
 hide frame c.
